package com.joyance.test_servlet.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class TestCookie extends HttpServlet {

    private static final long serialVersionUID = 1L;


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("Cookie================");
        Cookie[] cookies = req.getCookies();
        if (cookies != null && cookies.length > 0) {
            for (Cookie cookie : cookies) {
                // System.out.println("name=" + cookie.getName() + ",value=" + cookie.getValue());
                System.out.println("[getComment=" + cookie.getComment() + ",getDomain=" + cookie.getDomain() + ",getMaxAge=" + cookie.getMaxAge() + ",name="
                        + cookie.getName() + ",getPath=" + cookie.getPath() + ",getSecure=" + cookie.getSecure() + ",getValue=" + cookie.getValue()
                        + ",getVersion=" + cookie.getVersion() + "]");
            }
        }
    }

}
